using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Drawing.Design;
using System.Net;
using System.IO;
using System.Threading;
using System.Web.Security;

namespace ExtraClub.Domain {
    public class LayoutHolder : Panel {
        #region Properties
        #endregion

        #region Overridens
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
        }
        #endregion

        #region Method
        public void LoadByUri(string uri, string code_name, long verionId) {
        }
        public BaseModule LoadControl(string uri) {
            BaseModule control = null;
            if (!string.IsNullOrEmpty(uri)) {
                try {
                    if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal(uri, Page.User, "POST,GET")) {
                        FormsAuthentication.RedirectToLoginPage();
                        Page.Response.End();
                    }
                    control = (BaseModule)this.Page.LoadControl(ResolveUrl(uri));

                    this.Controls.Add(control);
                } catch (ThreadAbortException ex) {
                } catch (Exception ex) {
                    //throw ex;
                    Literal err = new Literal();
                    err.Text = string.Format(@"
<div style='margin:5px;padding:5px; border:solid 4px #777;color:red; background:#eee;'>
<p>Error:{0}</p>
<p>{1}<p></div>", ex.Message, uri);
                    this.Controls.Add(err);
                }
            }
            return control;
        }
        #endregion
    }
}
